package org.mklink.util;

import cn.hutool.core.util.StrUtil;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

/**
 * 文件处理工具类
 * @Author: wyx
 * @Date: 2023/8/20 12:22
 */
public class FileUtil extends cn.hutool.core.io.FileUtil {
    
    /**
     * 验证路径是否正确盘符路径
     * @param path
     * @return
     */
    public static boolean validPath(String path){
         if(StrUtil.isNotEmpty(path)){
            if(path.indexOf(":\\")>-1){
                return true;
            }
         }
         return false;
    }
    
    /**
     * 判断是否是软链接
     * @param file
     * @return
     * @throws IOException
     */
    public static boolean isLink(File file) throws IOException {
        if (file == null) {
            throw new NullPointerException("File must not be null");
        }
        Path path = file.toPath().toRealPath();
        return !path.equals(file.toPath());
    }
}
